﻿using UnityEngine;
using System.Collections;
using FairyGUI;

/// <summary>
/// 主界面顶部条
/// </summary>
public class UIHome_TopBar {

    GComponent _comp;
    UIHome_PlayerInfo _playerInfoCtrl;

    public UIHome_TopBar(GComponent comp)
    {
        _comp = comp;

        _playerInfoCtrl = new UIHome_PlayerInfo(_comp.GetChild("玩家信息").asCom);

		// 初始化邀请按钮
		GButton inviteBtn = _comp.GetChild("邀请按钮").asButton;
		inviteBtn.onClick.Add(() => {
			DebugInfo.Log("点击邀请按钮");

			GameController.inst.EnqueueMessage(
				new BaseProceduar.Message(Commands.CMD_CTRL_BUTTON_CLICKED, GameCommands.CMD_INVITE_FRIENDS)
			);
		});

        // 初始化玩法按钮
        GButton helpBtn = _comp.GetChild("玩法按钮").asButton;
        helpBtn.onClick.Add(() => {
            DebugInfo.Log("点击玩法按钮");
            UIHome_Help.Popup();
        });

        // 初始化充值按钮
        GButton chargeBtn = _comp.GetChild("充值按钮").asButton;
        chargeBtn.onClick.Add(() => {
            DebugInfo.Log("点击充值按钮");
            UIHome_Charge.Popup();
        });

		// 初始化设置按钮
		GButton setBtn = _comp.GetChild("设置按钮").asButton;
		setBtn.onClick.Add(() => {
			DebugInfo.Log("点击设置按钮");
			UIHome_Setting.Popup();
		});

		// 初始化消息按钮
		GButton msgBtn = _comp.GetChild("消息按钮").asButton;
		msgBtn.onClick.Add(() => {
			DebugInfo.Log("点击 消息按钮");
			UIHome_Message.Popup();
		});

		// 初始化战绩按钮
		GButton battleReportBtn = _comp.GetChild("战绩按钮").asButton;
		battleReportBtn.onClick.Add(() => {
			DebugInfo.Log("点击 战绩按钮");
			//UIHome_BattleReport.Popup();

			Hashtable reqArgs = new Hashtable();
			reqArgs["uid"] = DataKernel.inst.userInfo.uid;

			NetIOController.inst.SendMessage(
				new IOMessage(
					IOCmds.CMSG_REQ_GAME_REPORTS, IOStates.STATE_OK, new HashtableEx(reqArgs)));
		});
    }
}
